import Qt 4.7

Rectangle {
    property variant model
    property alias selected_dialog: container.selected_dialog
    signal clicked

    width: parent.width

    focus: true

    Rectangle {
        height: 50
        width: parent.width
        z: 2
        opacity: 0.8
        anchors.bottom: parent.bottom
    }

    Text {
        text: "No questions"
        visible: model.count === 0
    }

    ListView {
        id: container

        property int selected_dialog

        signal clicked

        model: parent.model

        onClicked: {
            parent.clicked()
        }

        width: parent.width
        height: parent.height

        delegate: Rectangle {
            id: listDelegate
            width: parent.width
            height: 60
            border.width: 1

            Text {
                text: name
                font.pixelSize: 40
                anchors.verticalCenter: parent.verticalCenter
                anchors.leftMargin: 25
                anchors.rightMargin: 25
            }

            MouseArea {
                id: mouse_area
                hoverEnabled: true
                anchors.fill: parent
                onClicked: {
                    container.selected_dialog = id
                    container.clicked();
               }
            }

            states: [
                State {
                    name: "focused"
                    when: mouse_area.containsMouse == true && mouse_area.pressed == false
                    PropertyChanges {
                        target: listDelegate
                        color: "#EEE"
                    }
                },
                State {
                    name: "pressed"
                    when: mouse_area.pressed == true
                    PropertyChanges {
                        target: listDelegate
                        color: "#BBB"
                    }

                }
            ]
        }
    }
}
